fix clang 15 warnings on windows (#1132)
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Fri, 23 Jun 2023 22:15:35 +0000 (16:15 -0600)
committerGitHub <noreply@github.com>
Fri, 23 Jun 2023 22:15:35 +0000 (16:15 -0600)
* fix some format specifier issues

that came to light trying to get clang to work under visual studio.

* fix another windows only warning

* fix some more wordsize issues.

exif.cc
garmin_fit.cc
garmin_gpi.cc
inifile.cc
jeeps/gpsusbwin.cc
wbt-200.cc

diff --git a/exif.cc b/exif.cc
index da634db51aeb30a821ceba94544bb1824ef4baab..25bcd7b06a8bb5b6a5450699bbdfad77f0ac9dac 100644 (file)
--- a/exif.cc
+++ b/exif.cc
@@ -59,7 +59,7 @@
 #include <cmath>                // for fabs, modf, copysign, round, fmax
 #include <cstdint>              // for uint32_t, int32_t, uint16_t, int16_t, uint8_t, INT32_MAX
 #include <cstdio>               // for printf, SEEK_SET, snprintf, SEEK_CUR
-#include <cstdlib>              // for labs
+#include <cstdlib>              // for abs
 #include <cstring>              // for memcmp, strlen
 #include <type_traits>          // for add_const<>::type
 
@@ -1159,7 +1159,7 @@ ExifFormat::exif_find_wpt_by_time(const Waypoint* wpt)
 
   if (exif_wpt_ref == nullptr) {
     exif_wpt_ref = wpt;
-  } else if (labs(exif_time_ref.msecsTo(wpt->creation_time)) < labs(exif_time_ref.msecsTo(exif_wpt_ref->creation_time))) {
+  } else if (std::abs(exif_time_ref.msecsTo(wpt->creation_time)) < std::abs(exif_time_ref.msecsTo(exif_wpt_ref->creation_time))) {
     exif_wpt_ref = wpt;
   }
 }
@@ -1535,13 +1535,13 @@ ExifFormat::write()
 
     if (exif_wpt_ref == nullptr) {
       warning(MYNAME ": No point with a valid timestamp found.\n");
-    } else if (labs(exif_time_ref.secsTo(exif_wpt_ref->creation_time)) > frame) {
+    } else if (std::abs(exif_time_ref.secsTo(exif_wpt_ref->creation_time)) > frame) {
       QString time_str = exif_time_str(exif_time_ref);
       warning(MYNAME ": No matching point found for image date %s!\n", qPrintable(time_str));
       if (exif_wpt_ref != nullptr) {
         QString str = exif_time_str(exif_wpt_ref->creation_time);
-        warning(MYNAME ": Best is from %s, %ld second(s) away.\n",
-                qPrintable(str), labs(exif_time_ref.secsTo(exif_wpt_ref->creation_time)));
+        warning(MYNAME ": Best is from %s, %lld second(s) away.\n",
+                qPrintable(str), std::abs(exif_time_ref.secsTo(exif_wpt_ref->creation_time)));
       }
       exif_wpt_ref = nullptr;
     }
index 0cc111d035b7fcfacd1579b95a29a4fd1e7d55d1..3982216f8a5453d4ec0ff6edba7391dbee85643a 100644 (file)
@@ -865,7 +865,7 @@ GarminFitFormat::read()
   } catch (ReaderException& e) {
     if (opt_recoverymode) {
       warning(MYNAME ": %s\n",e.what());
-      warning(MYNAME ": Aborting read and continuning processing.\n");
+      warning(MYNAME ": Aborting read and continuing processing.\n");
     } else {
       fatal(MYNAME ": %s  Use recoverymode option at your risk.\n",e.what());
     }
index 4ec4661cae9de7c7e21c31093d34527c651a7f15..473871bb234419e6c9ce2e24b2f5cee8e35fa70d 100644 (file)
@@ -176,7 +176,7 @@ GarminGPIFormat::read_header()
   rdata->crdate = gbfgetint32(fin);
   if (GPI_DBG) {
     time_t crdate = GPS_Math_Gtime_To_Utime(rdata->crdate);
-    warning("crdate = %lu (%s)\n", rdata->crdate,
+    warning("crdate = %lld (%s)\n", (long long) rdata->crdate,
             CSTR(QDateTime::fromSecsSinceEpoch(crdate, Qt::UTC).toString(Qt::ISODate)));
   }
 
index 3daa49c8d2ada815d2338789dd90555c49d64aa5..be1e28a7029438b5ff5066fc8b30b6ac7b5e63b3 100644 (file)
@@ -52,7 +52,9 @@ public:
 /* internal procedures */
 
 static constexpr char GPSBABEL_INIFILE[] = "gpsbabel.ini";
+#ifndef __WIN32__
 static constexpr char GPSBABEL_SUBDIR[] = ".gpsbabel";
+#endif
 
 
 static QString
index 5cec69609773993cb46931f30a3c21eafb02b9c2..6ed6e68547599dba1effc827edaa0116c8cc1418 100644 (file)
@@ -117,7 +117,7 @@ gusb_win_send(const garmin_usb_packet* opkt, size_t sz)
   WriteFile(usb_handle, obuf, sz, &rsz, NULL);
 
   if (rsz != sz) {
-    fatal("Error sending %d bytes.   Successfully sent %ld\n", sz, rsz);
+    fatal("Error sending %zu bytes.  Successfully sent %ld\n", sz, rsz);
   }
 
   return rsz;
index 75f16aff124154ab6f0c63059fcf123536f3cf4c..f88b5428609e32cfadf7109199b32ee61c3a6d64 100644 (file)
@@ -614,7 +614,7 @@ static bool is_valid(struct buf_head* h, int fmt)
 
   buf_rewind(h);
 
-  db(2, "Checking %lu bytes of data against format %d\n", h->used, fmt);
+  db(2, "Checking %zu bytes of data against format %d\n", h->used, fmt);
 
   for (;;) {
     size_t got = buf_read(h, buf, reclen);
@@ -650,7 +650,7 @@ static void wbt200_process_data(struct read_state* pst, int fmt)
 
   buf_rewind(&pst->data);
 
-  db(2, "Processing %lu bytes of data using format %d\n", pst->data.used, fmt);
+  db(2, "Processing %zu bytes of data using format %d\n", pst->data.used, fmt);
 
   for (;;) {
     size_t got = buf_read(&pst->data, buf, reclen);
@@ -843,7 +843,7 @@ static void wbt201_process_chunk(struct read_state* st)
 {
   char buf[RECLEN_WBT201];
 
-  db(2, "Processing %lu bytes of data\n", st->data.used);
+  db(2, "Processing %zu bytes of data\n", st->data.used);
 
   while (buf_read(&st->data, buf, sizeof(buf)) == sizeof(buf)
          && wbt201_data_chunk(st, buf)) {